# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer:
pkgname=spdlog
pkgver=1.7.0
pkgrel=2
pkgdesc="Fast C++ logging library"
url="https://github.com/gabime/spdlog"
arch="all"
license="MIT"
makedepends="cmake fmt-dev"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/gabime/spdlog/archive/v$pkgver.tar.gz"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
		-DSPDLOG_BUILD_BENCH=OFF \
		-DSPDLOG_BUILD_TESTS=ON \
		-DSPDLOG_SANITIZE_ADDRESS=OFF \
		-DSPDLOG_FMT_EXTERNAL=ON \
		-DSPDLOG_BUILD_SHARED=ON \
		-DSPDLOG_BUILD_EXAMPLE=OFF \
		$CMAKE_CROSSOPTS .
	make -C build
}

check() {
	make -C build test
}

package() {
	make -C build DESTDIR="$pkgdir" install
	sed -e 's|.*#define SPDLOG_FMT_EXTERNAL|#define SPDLOG_FMT_EXTERNAL|' \
		-i "$pkgdir"/usr/include/spdlog/tweakme.h
}

sha512sums="e15d461ac7a6d3d3186fe4283e4fbaf56b2ce3011babf892e3b2d3dbdd7e999a861f1f6f67a9d88a5cf488a440add087ea78e96131f49b52ed6c7815a972799a  spdlog-1.7.0.tar.gz"
